#!/bin/sh
#挂载ysytem 
dirfs=/mnt/sys
root_fs="/dev/disk/by-id/dm-uuid-LVM-2kXUMvnZlZy3t0tMl3zgTaZ6bZUvunmULpPSgzA2gTVTmSTgs2FXoZ9M3UBEBiEL"
rm -rf $dirfs
mkdir -p $dirfs
mount -o rw $root_fs $dirfs
rm -rfv $dirfs/*

echo "正在安装系统"



cd /
echo "Copy BIN"
tar -cf - bin | (cd $dirfs; tar -xpf -)
#echo "Copy BOOT"
#mkdir -p $dirfs/boot
#tar -cf - boot | (cd $dirfs; tar -xpf -)
echo "Create DEV"
mkdir -p $dirfs/dev
#tar -cf - dev | (cd $dirfs; tar -xpf -)
echo "Copy ETC"
tar -cf - etc | (cd $dirfs; tar -xpf -)
echo "Copy HOME"
tar -cf - home | (cd $dirfs; tar -xpf -)
echo "Copy LIB"
tar -cf - lib | (cd $dirfs; tar -xpf -)
echo "Copy LIB64"
tar -cf - lib64 | (cd $dirfs; tar -xpf -)
echo "Create MEDIA"
mkdir -p $dirfs/media
#tar -cf - media | (cd $dirfs; tar -xpf -)
echo "Create MNT"
mkdir -p $dirfs/mnt
#tar -cf - mnt | (cd $dirfs; tar -xpf -)
echo "Copy OPT"
tar -cf - opt | (cd $dirfs; tar -xpf -)
echo "Create PROC"
mkdir -p $dirfs/proc
echo "Copy ROOT"
tar -cf - root | (cd $dirfs; tar -xpf -)
echo "Create RUN"
mkdir -p $dirfs/run
echo "Copy SBIN"
tar -cf - sbin | (cd $dirfs; tar -xpf -)
echo "Copy SELINUX"
tar -cf - selinux | (cd $dirfs; tar -xpf -)
echo "Copy SRV"
tar -cf - srv | (cd $dirfs; tar -xpf -)
echo "Create SYS"
mkdir -p $dirfs/sys
echo "Create TMP"
mkdir -p $dirfs/tmp
echo "Copy USR"
tar -cf - usr | (cd $dirfs; tar -xpf -)
echo "Copy VAR"
tar -cf - var | (cd $dirfs; tar -xpf -)
sync



#/etc/fstab
cat > $dirfs/etc/fstab << EOF
# 挂载系统分区
/dev/disk/by-id/dm-uuid-LVM-2kXUMvnZlZy3t0tMl3zgTaZ6bZUvunmULpPSgzA2gTVTmSTgs2FXoZ9M3UBEBiEL / ext4 defaults 0 1
# 挂载 boot 分区
/dev/disk/by-uuid/47e7c36f-1847-4af3-8391-5cc80afb5ad5 /boot ext4 defaults 0 1

EOF
echo "复制系统完成"
#卸载系统
umount -f $root_fs
sync



